package com.javase.A04;

public class bubbleSort {

    public static void main(String[] args) {
        int[] ints = {25,24,12,76,101,96,28};
        System.out.print("冒泡排序前：");
        printArr(ints);
        sort(ints);
        System.out.print("冒泡排序后：");
        printArr(ints);
    }


    public static void printArr(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
        System.out.println();
    }

    public static void sort(int[] arr){
        int temp=0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = i+1; j < arr.length ; j++) {
                if (arr[i]>arr[j]){
                    temp=arr[i];
                    arr[i]=arr[j];
                    arr[j]=temp;
                }
            }
            System.out.print("第"+(i+1)+"轮打印输出：");
            printArr(arr);
        }
    }
}
